home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-12-08 | 7.1 KB | 291 lines | [TEXT/MPS ] |
- /*
- File: Panel.h
-
- Contains: Panel Classes Definition
-
- Written by: Steve Smith
-
- Copyright: © 1995 by Apple Computer, Inc., all rights reserved.
- */
-
- // -- PanelEditor Includes --
-
- #ifndef _PANEL_
- #include "Panel.h"
- #endif
-
- #ifndef _LISTITEM_
- #include "ListItem.h"
- #endif
-
- #ifndef _PANELEDITORDEF_
- #include "PanelEditorDef.h"
- #endif
-
- #ifndef _PANELEDITORUTILS_
- #include "PanelEditorUtils.h"
- #endif
-
- #ifndef _SAMPLECOLLECTIONS_
- #include "SampleCollections.h"
- #endif
-
- // -- OpenDoc Includes --
-
- #ifndef _ODTYPES_
- #include <ODTypes.h>
- #endif
-
- #ifndef SOM_ODPart_xh
- #include <Part.xh>
- #endif
-
- #ifndef SOM_ODFacet_xh
- #include <Facet.xh>
- #endif
-
- #ifndef SOM_ODFrame_xh
- #include <Frame.xh>
- #endif
-
- #ifndef SOM_ODFrameFacetIterator_xh
- #include <FrFaItr.xh>
- #endif
-
- #ifndef SOM_ODDraft_xh
- #include <Draft.xh>
- #endif
-
- // -- OpenDoc Utilities --
-
- #ifndef _ODUTILS_
- #include <ODUtils.h>
- #endif
-
- #ifndef _EXCEPT_
- #include <Except.h>
- #endif
-
- #ifndef _TEMPOBJ_
- #include <TempObj.h>
- #endif
-
- #ifndef _TEMPITER_
- #include <TempIter.h>
- #endif
-
-
- #pragma segment PanelEditorPanel
-
- //==============================================================================
- // CPanel
- //==============================================================================
-
- //------------------------------------------------------------------------------
- // Method: Constructor
- //
- // Description: This is the C++ class constructor.
- //------------------------------------------------------------------------------
-
- CPanel::CPanel()
- {
- fHasFrames = kODFalse;
- }
-
- //------------------------------------------------------------------------------
- // Method: InitPanel
- //
- // Description: This is the C++ class constructor.
- //------------------------------------------------------------------------------
-
- void CPanel::InitPanel()
- {
- this->InitFrame();
- }
-
- //------------------------------------------------------------------------------
- // Method: Destructor
- //
- // Description: This is the C++ class Destructor.
- //------------------------------------------------------------------------------
-
- CPanel::~CPanel()
- {
- ASSERT(fInited != kODFalse, kAssertionFailed);
- }
-
- //------------------------------------------------------------------------------
- // Method: CreateFrames
- //
- // Description: This method is called in response to
- //------------------------------------------------------------------------------
-
- void CPanel::CreateFrames( Environment* ev )
- {
- inherited::CreateFrames(ev);
- fHasFrames = kODTrue;
- }
-
- //------------------------------------------------------------------------------
- // Method: AddFrame
- //
- // Description: This method is called in response to
- //------------------------------------------------------------------------------
-
- void CPanel::AddFrame( Environment* ev, ODFrame* containingFrame )
- {
- ASSERT(fInited != kODFalse, kAssertionFailed);
-
- // We lazily create the frames and facets because we dont' know
- // which part is in the "selection" until facets have been created.
- fContainingFrames->Add(containingFrame);
-
- // But, if we've already created and displayed frames, then we need to
- // add a new frame now.
- if ( fHasFrames )
- this->NewFrame(ev, containingFrame);
- }
-
- //------------------------------------------------------------------------------
- // Method: RemoveAll
- //
- // Description: This method is called in response to
- //------------------------------------------------------------------------------
-
- ODFrame* CPanel::GetContainedFrame(Environment* ev, ODFrame* containingFrame)
- {
- ODFrame* containedFrame = kODNULL;
-
- CFrameListIterator fiter(fFrames);
- for ( ODFrame* frame=fiter.First();fiter.IsNotComplete();
- frame=fiter.Next() )
- {
- TempODFrame parentFrame = frame->AcquireContainingFrame(ev);
- if ( ODObjectsAreEqual(ev, parentFrame, containingFrame) )
- {
- containedFrame = frame;
- break;
- }
- }
-
- return containedFrame;
- }
-
- //------------------------------------------------------------------------------
- // Method: RemoveAll
- //
- // Description: This method is called in response to
- //------------------------------------------------------------------------------
-
- void CPanel::RemoveAll( Environment* ev )
- {
- inherited::RemoveAll(ev);
- fHasFrames = kODFalse;
- }
-
-
- //------------------------------------------------------------------------------
- // Method: AddFacet
- //
- // Description: This method is called when
- //------------------------------------------------------------------------------
-
- void CPanel::AddFacet(Environment* ev, ODFacet* containingFacet)
- {
- // Things are done lazily, so don't create a facet unless we
- // really need to.
-
- if ( fHasFrames )
- inherited::AddFacet(ev,containingFacet);
- }
-
- //------------------------------------------------------------------------------
- // Method: Draw
- //
- // Description: This method is called in response to an update event.
- //------------------------------------------------------------------------------
-
- void CPanel::Draw(Environment* ev, ODFacet* containingFacet)
- {
- ODFrame* containingFrame = containingFacet->GetFrame(ev);
-
- // Leave space for the grow box and status line area.
- ODUShort slHeight = (containingFrame->IsRoot(ev)) ? 15 : 0;
-
- Rect box;
- GetQDFrameBounds(ev, containingFrame, &box);
-
- box.left = kPanelLeftEdge;
- box.top += kPanelTopEdge;
- box.right -= kPanelTopEdge;
- box.bottom -= (kPanelTopEdge+slHeight);
-
- PenNormal();
- FrameRect(&box);
- }
-
- //------------------------------------------------------------------------------
- // Method: GetFrameBounds
- //
- // Description: This method is called in response to an update event.
- //------------------------------------------------------------------------------
-
- ODRect CPanel::GetFrameBounds(Environment* ev, ODFrame* containingFrame)
- {
- ODRect bounds;
- TempODShape frameShape = containingFrame->AcquireFrameShape(ev, kODNULL);
- frameShape->GetBoundingBox(ev, &bounds);
-
- // Leave space for the grow box and status line area.
- ODUShort slHeight = (containingFrame->IsRoot(ev)) ? 15 : 0;
-
- bounds.top = 0;
- bounds.left = 0;
- bounds.bottom -= ff(2*kPanelTopEdge+2+slHeight);
- bounds.right -= ff(kPanelLeftEdge+kPanelTopEdge+2);
-
- return bounds;
- }
-
- //------------------------------------------------------------------------------
- // Method: ChangeDisplayItem
- //
- // Description: This method is called in response to
- //------------------------------------------------------------------------------
-
- void CPanel::ChangeDisplayItem(Environment* ev, CListItem* item)
- {
- ASSERT(fInited != kODFalse, kAssertionFailed);
-
- ODReleaseObject(ev, fPartDisplayed);
- fPartDisplayed = item->AcquirePart(ev);
-
- if ( fHasFrames == kODFalse )
- {
- this->CreateFrames(ev);
- this->CreateFacets(ev);
- }
-
- CFrameListIterator fiter(fFrames);
- for ( ODFrame* frame=fiter.First();fiter.IsNotComplete();
- frame=fiter.Next() )
- {
- // Reset the frame characteristics, so the new owner won't get confused.
- TempODShape usedShape = ODCopyAndRelease(ev, frame->AcquireFrameShape(ev, kODNULL));
- frame->ChangeUsedShape(ev, usedShape, kODNULL);
- TempODFrameFacetIterator fiter(ev, frame);
- for ( ODFacet* facet = fiter.First(); fiter.IsNotComplete();
- facet = fiter.Next() )
- {
- facet->ChangeActiveShape(ev, kODNULL, kODNULL);
- }
-
- // Change owners.
- frame->ChangePart(ev, fPartDisplayed);
- frame->Invalidate(ev, kODNULL, kODNULL);
- }
- }
-
-
-
-